import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:hook_up_rent/widgets/common_image.dart';

//定义图片数组
const List<String> defaultImage=[
   'https://ww3.sinaimg.cn/large/006y8mN6ly1g6e2tdgve1j30ku0bsn75.jpg',
   'https://ww3.sinaimg.cn/large/006y8mN6ly1g6e2whp87sj30ku0bstec.jpg',
   'https://ww3.sinaimg.cn/large/006y8mN6ly1g6e2tl1v3bj30ku0bs77z.jpg'
];

const imageWidth = 750.0;
const imageHeight = 424.0;

class CommonSwiper extends StatelessWidget {

  final List<String> images;

  const CommonSwiper({Key key, this.images = defaultImage }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final height = MediaQuery.of(context).size.width / imageWidth * imageHeight;
    return Container(
      height: height,
      child:Swiper(
        autoplay: true,
        itemBuilder: (BuildContext context, int index){
          return CommonImage(defaultImage[index]);
        },
        itemCount: images.length,
        pagination: SwiperPagination(),
        control: SwiperControl(),
      )
    );
  }
}